package com.ymatou.iapi.sellerproduct.testcase;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.sellerproduct.parameter.ActivityProductsGetBean;
import com.ymatou.iapi.sellerproduct.service.ActivityProductsGetCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;

public class Ts_ActivityProductsGet {
	private static ActivityProductsGetBean activityproductsgetBean;
	private static ActivityProductsGetCall activityproductsgetCall;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取直播下所有商品");
	}
	
	@Before
	public void caseUp() {
		activityproductsgetBean = new ActivityProductsGetBean();
		activityproductsgetCall = new ActivityProductsGetCall();	
	}
	
	@AfterClass
	public static void tearDown() {
		Logger.generateResult(activityproductsgetCall.getOpurl());
	}
	
	@After
	public void caseDown() {
		Logger.end();
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ActivityProductsGet_001() {
		Logger.start(true,"获取直播下所有商品");
		try{
			activityproductsgetBean.setActivityId(149629);
			activityproductsgetBean.setIsNewCatalog(true);
			activityproductsgetBean.setPageSize(10);
			activityproductsgetBean.setTabIndex(2);
			activityproductsgetBean.setUserId(20227567);
			
			
			activityproductsgetCall.setData(activityproductsgetBean);
			
			activityproductsgetCall.callService();
			
			//获取返回报文的数据
			
			String dataStr = activityproductsgetCall.getReturnData();
			//返回报文断言
			Logger.verifyNotNull(dataStr, "返回报文非空");
			//断言"Code":200
			String code =  new JSONObject(dataStr).getString("Code");
			Logger.verifyIsContains(code, 200, "\"Code\":200");
			//断言"Msg":""
			String msg =  new JSONObject(dataStr).getString("Msg");
			Logger.verifyIsNull(msg, "Msg等于空");
			
			
			//Todo 检查数据库 sqlserver mongo
			
		}catch(Exception e){
			Logger.fail(e);
		}
		
		
	}
}
